from django.contrib.auth.models import User
from django.db import models

class Group(models.Model):
    name = models.CharField(max_length=50)
    members = models.ManyToManyField(User, through="Membership")

    class Meta:
        app_label = "core"
        
    def __unicode__(self):
    	return " - ".join([unicode(self.id), unicode(self.name)])

class Membership(models.Model):
    is_admin = models.BooleanField()
    is_creator = models.BooleanField()
    is_banned = models.BooleanField()
    can_add_tasks = models.BooleanField()
    can_edit_tasks = models.BooleanField()
    can_change_memberships = models.BooleanField()
    user = models.ForeignKey(User)
    group = models.ForeignKey(Group)

    class Meta:
        app_label = "core"
        
    def __unicode__(self):
    	return " - ".join([unicode(self.id), unicode(self.user) + " <-> " + unicode(self.group), unicode(self.is_admin),
    					   unicode(self.is_creator), unicode(self.is_banned)])
